/****************************************************************************
*  Title: inputoutput.sc
*  Author: Anthony Schaefer, Umar Butt, Talha Ansari
*  Date: 04/01/2010
*  Description: IO behavior that reads input from command line and prints answer
****************************************************************************/

#include <stdio.h>
//import "c_queue";
import "communication";

/* if want to use with c_queue somehow */
//behavior inputoutput (i_sender firstData, i_sender operatorData,
//					i_sender secondData,  i_receiver outputData)
behavior inputoutput (TwoWayHandShaking firstData, TwoWayHandShaking operatorData,
					TwoWayHandShaking secondData, TwoWayHandShaking outputData)
{

	float a, b, c;
	char d;
	
	void main(void) {		
		while (1)
		{
			printf("Enter the first number: ");
			scanf("%f",&a);
			getchar();
			
			printf("Enter operator (/, *, +, -): ");
			scanf("%c",&d);
			getchar();
			
			printf("Enter the second number: ");
			scanf("%f",&b);
			getchar();
			
			/* if want to use with c_queue somehow */
			//firstData.send(&a, 1);
			//operatorData.send(&d, 1);
			//secondData.send(&b, 1);
			
			/* Send user entered data for computation */
			firstData.Send(a);
			operatorData.Send(d);
			secondData.Send(b);
			
			/* if want to use with c_queue somehow */
			//outputData.receive(&c, 1);
			
			/* Receive result and then display */
			c = outputData.Receive();
			printf("Answer is %f \n\n",c);
		}

	}
};
